﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Mono.Cecil;
using Mono.Cecil.Cil;

namespace Hiro.Interfaces
{
    /// <summary>
    /// Represents a class that can determine whether or not enough dependencies exist within a given <see cref="IDependencyMap"/>
    /// to emit the instructions necessary to instantiate the current type.
    /// </summary>
    public interface IActivationPoint
    {
        /// <summary>
        /// Determines whether or not the current <see cref="IDependencyMap"/> has the necessary
        /// dependencies for the current activation point to emit the necessary IL to instantiate the current type.
        /// </summary>
        /// <param name="dependencyContainer">The target dependency container.</param>
        /// <returns><c>true</c> if all required dependencies can be instantiated; otherwise, it will return <c>false</c>.</returns>
        bool IsValidWith(IDependencyContainer dependencyContainer);

        /// <summary>
        /// Emits the necessary <paramref name="IL"/> instructions to instantiate the current type.
        /// </summary>
        /// <param name="targetMethod">The method that will instantiate the current type.</param>
        /// <param name="IL">The <see cref="CilWorker"/> that points to the method body of the method that will instantiate the current type.</param>
        /// <param name="hostModule">The module that contains the container type.</param>
        /// <param name="dependencyMap">The dependency map that describes the list of dependencies in the current application.</param>
        [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1709:IdentifiersShouldBeCasedCorrectly", MessageId = "IL", Justification = "The parameter is named 'IL' since the class is working with an IL generator.")]
        void Emit(MethodReference targetMethod, CilWorker IL, ModuleDefinition hostModule, IDependencyMap dependencyMap);
    }
}
